/**
 * @author tongchen
 * @create 2023-02-01 20:14
 */
public class decimalByBinary {
    public static void main(String[] args) {
        //创建二进制数
        Double num=0.625;
        //创建stringbuilder进行字符串的拼接
        StringBuilder stringBuilder=new StringBuilder();
        stringBuilder.append("0.");
        //判断数字是否大于0
        while(num>0){
            //num*2
            num*=2;
            if(num>=1){
                stringBuilder.append("1");
                num-=1;
            }
            else {
                stringBuilder.append("0");
            }
            //最后判断数字stringBuilder的位数
            if(stringBuilder.length()>34){
                System.out.println("ERROR");
                return;
            }
        }
        System.out.println(stringBuilder.toString());
    }
}
